﻿<mui:MetroWindow  x:Class="wStore.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mui="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
        xmlns:tb="http://www.hardcodet.net/taskbar" 
        ResizeMode="CanResizeWithGrip" ShowIconOnTitleBar="True" GlowBrush="Silver"
        Title="W.I.N.C.O. AppStore" Height="600" Width="800"
        SnapsToDevicePixels="True" BorderThickness="1">

  
  <mui:MetroWindow.Effect>
    <DropShadowEffect Direction="0"/>
  </mui:MetroWindow.Effect>

  <mui:MetroWindow.WindowCommands>
      <mui:WindowCommands>
        <Button Content="settings" Click="btSettings_Click" />
        <!--<Button>
          <StackPanel Orientation="Horizontal">
            <Rectangle Width="20" Height="20">
              <Rectangle.Resources>
                <SolidColorBrush x:Key="BlackBrush" Color="White" />
              </Rectangle.Resources>
              <Rectangle.Fill>
                <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_cupcake}" />
              </Rectangle.Fill>
            </Rectangle>
            <TextBlock Text="deploy cupcakes" />
          </StackPanel>
        </Button>-->
      </mui:WindowCommands>
    </mui:MetroWindow.WindowCommands>

  <mui:MetroWindow.Flyouts>
    <mui:FlyoutsControl>
      <mui:Flyout x:Name="settingsFlyout" Background="White" Width="500" Header="Settings" Position="Right">
        <Grid Margin="10">
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
          </Grid.RowDefinitions>
          <TextBlock Grid.Row="0" Text="Something above the ScrollPanel" />

          <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
            <StackPanel Orientation="Vertical">
              <TextBox mui:TextboxHelper.Watermark="TextBox 01" />
              <TextBox Margin="0,5,0,0" mui:TextboxHelper.Watermark="TextBox 02" />
            </StackPanel>
          </ScrollViewer>

          <UniformGrid Columns="2"
                                 Grid.Row="2"
                                 Margin="10">
            <Button Style="{DynamicResource SquareButtonStyle}"
                                Margin="10"
                                Content="Create" />
            <Button Style="{DynamicResource SquareButtonStyle}"
                                Margin="10"
                                Content="Cancel" />
          </UniformGrid>

        </Grid>
      </mui:Flyout>
    </mui:FlyoutsControl>
  </mui:MetroWindow.Flyouts>



  <mui:MetroContentControl>
    <Grid>
      <tb:TaskbarIcon x:Name="myNotifyIcon" Visibility="Visible" IconSource="/Icon1.ico" ToolTipText="wAppStore is best !" />

    <mui:MetroAnimatedSingleRowTabControl>
      <TabItem Header="applications">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
          <StackPanel Orientation="Horizontal"  >
            <ComboBox Margin="8,4" ItemsSource="{Binding PlatformList}"
                      SelectedItem="{Binding SelectedPlatform}" MinWidth="150" 
                      DisplayMemberPath="Title"   />
              <TextBlock Text="Sort by: " VerticalAlignment="Center" />
              <TextBlock VerticalAlignment="Center" Margin="4">Released</TextBlock>
              <TextBlock VerticalAlignment="Center" Margin="4">Title</TextBlock>
              <TextBlock VerticalAlignment="Center" Margin="4">Downloaded</TextBlock>
              <TextBlock VerticalAlignment="Center" Margin="4">Liked</TextBlock>

              <!--<ComboBox Name="cbCategory" Margin="2"  ItemsSource="{Binding CategoryList}" 
                SelectedItem="{Binding SelectedCategory}"
                DisplayMemberPath="Name" MinWidth="150" />-->
          </StackPanel>
            <TextBox Grid.Column="1" Margin="8,4" mui:TextboxHelper.Watermark="Search..." HorizontalAlignment="Stretch"
                     Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
                     Style="{DynamicResource SearchMetroTextBox}" 
              mui:TextboxHelper.ButtonCommand="{Binding LoadAppCmd, Mode=OneWay}">
              <TextBox.InputBindings>
                <KeyBinding Command="{Binding LoadAppCmd}" Key="Enter"/>
              </TextBox.InputBindings>
            </TextBox>


            <Grid Grid.Row="1" Grid.ColumnSpan="2">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>

              <ListView Grid.Column="0" Margin="8"  FontSize="20" BorderBrush="Transparent"
                ItemsSource="{Binding CategoryList}" SelectedItem="{Binding SelectedCategory}"  DisplayMemberPath="Name" >
              </ListView>
              <ListView Grid.Column="1" ItemsSource="{Binding AppList}" BorderBrush="Transparent" >
                <ListBox.ItemsPanel>
                  <ItemsPanelTemplate>
                    <WrapPanel Width="{Binding (FrameworkElement.ActualWidth), 
            RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
            ItemWidth="{Binding (ListView.View).ItemWidth, 
            RelativeSource={RelativeSource AncestorType=ListView}}"
            MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
            ItemHeight="{Binding (ListView.View).ItemHeight, 
            RelativeSource={RelativeSource AncestorType=ListView}}" />
                  </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                  <DataTemplate>
                    <Grid Width="240" Margin="4"  >
                      <Grid.Resources>
                        <Style TargetType="TextBlock">
                          <Setter Property="Foreground" Value="Black"/>
                          <Setter Property="TextWrapping" Value="Wrap" />
                          <Setter Property="Padding" Value="4" />
                          <Setter Property="FontSize" Value="14" />
                          <Setter Property="HorizontalAlignment" Value="Stretch" />
                          <Setter Property="VerticalAlignment" Value="Bottom" />

                        </Style>
                      </Grid.Resources>
                      <Border BorderBrush="WhiteSmoke" BorderThickness="0" Background="White" Opacity="0.95" >
                        <Grid>
                          <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                          </Grid.RowDefinitions>

                          <TextBlock Text="{Binding wApp.Name}" Grid.Row="0" Margin="0,0,0,4" FontSize="16" Foreground="White" 
                        HorizontalAlignment="Stretch" Background="{StaticResource WindowTitleColorBrush}"/>

                          <Grid Grid.Row="1">
                            <Grid.ColumnDefinitions>
                              <ColumnDefinition Width="110" />
                              <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <Grid Margin="0,0,8,0">
                              <Image HorizontalAlignment="Left" VerticalAlignment="Top" 
                           Source="{Binding wApp.Icon}" ToolTip="{Binding wApp.ShortInfo}" />
                            </Grid>

                            <StackPanel Grid.Row="1" Grid.Column="1" >
                              <TextBlock Text="{Binding wApp.Modified, StringFormat=d}" HorizontalAlignment="Right" />
                              <TextBlock HorizontalAlignment="Right">
                          <Run Text="{Binding wApp.Downloads}" />
                          <Run Text="/"/>
                          <Run Text="{Binding wApp.Likes}" />
                              </TextBlock>
                              <Separator Background="{StaticResource WindowTitleColorBrush}"/>
                              <TextBlock TextWrapping="Wrap" Text="{Binding wApp.ShortInfo}" FontSize="12" />
                            </StackPanel>
                          </Grid>
                          <StackPanel Margin="8" Orientation="Horizontal" Grid.Row="2" Background="WhiteSmoke" >
                            <Button Content="Try it" Margin="4" Width="60" Command="{Binding TryItCommand}" />
                            <Button Content="Like it" Margin="4" Width="60" Command="{Binding LikeItCommand}" />
                            <Button Content="Share it" Margin="4" Width="60" Command="{Binding ShareItCommand}" />
                          </StackPanel>
                          <!--<ScrollViewer Grid.Row="2" Background="WhiteSmoke" VerticalAlignment="Stretch">
                        <StackPanel>
                          <TextBlock Text="Description" FontStyle="Italic" FontSize="12"/>
                          <TextBlock TextWrapping="Wrap" Text="{Binding wApp.Description}" FontSize="12" />
                        </StackPanel>
                      </ScrollViewer>-->
                        </Grid>
                        <!-- , FallbackValue='pack://siteoforigin:,,,/Images/PCP.png'}"  /> -->
                      </Border>
                    </Grid>
                  </DataTemplate>
                </ListBox.ItemTemplate>
              </ListView>
            </Grid>
          
          </Grid>
      </TabItem>

        <TabItem Header="installed" >
        </TabItem>

        <TabItem Header="favorites" >
        </TabItem>
      
        <TabItem Header="about">
        <Grid></Grid>
      </TabItem>
    </mui:MetroAnimatedSingleRowTabControl>
    </Grid>
  </mui:MetroContentControl>


</mui:MetroWindow>
